﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SaleOfMoviesSystem.Xml.Models;

namespace SaleOfMoviesSystem.Xml
{
    public partial class UCTicket : UserControl
    {
        public UCTicket()
        {
            InitializeComponent();
        }

        public Ticket Ticket { get; set; }

        public UCTicket(Ticket ticket)
        {
            InitializeComponent();

            Ticket = ticket;
            label1.Text = ticket.TicketName;
            if (ticket.IsSaled)
            {
                this.BackColor = Color.Red;
            }
            else
            {
                BackColor = SystemColors.Control;
            }
            // todo: 不起作用？？？
            //this.Click += UCTicket_Click;
        }

        //private void UCTicket_Click(object sender, EventArgs e)
        //{
        //    if (Ticket.IsSaled)
        //    {
        //        MessageBox.Show("该票已经出售!");
        //    }
        //    else
        //    {
        //        if (BackColor == Color.Yellow)
        //        {
        //            BackColor = SystemColors.Control;
        //        }
        //        else
        //        {
        //            BackColor = Color.Yellow;
        //        }
        //    }
        //    //throw new NotImplementedException();
        //}

        private void label1_Click(object sender, EventArgs e)
        {
            if (Ticket.IsSaled)
            {
                MessageBox.Show("该票已经出售!");
            }
            else
            {
                if (BackColor == Color.Yellow)
                {
                    BackColor = SystemColors.Control;
                }
                else
                {
                    BackColor = Color.Yellow;
                }
            }
        }

        //private void UCTicket_Click_1(object sender, EventArgs e)
        //{
        //}

        //private void label1_Click(object sender, EventArgs e)
        //{
        //}
    }
}